package jinyilw.swing.visuals.text;

import jinyilw.swing.FontTools;
import jinyilw.swing.i18n.ICSetting;
import jinyilw.swing.visuals.Icomp.ILabel;
import jinyilw.swing.visuals.border.RTitledBorder;

import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
import java.awt.Color;

public class WrapTextPane extends JPanel
{
	private static final long serialVersionUID = 8248219365817300460L;
	private final ILabel editorPane = new ILabel();
	private RTitledBorder titledBorder;

	public WrapTextPane()
	{
	}
	public void setText(String text)
	{
		editorPane.setText(text);
	}

	public void setText(ICSetting iSetting)
	{
		editorPane.setText(iSetting);
	}

	public void setTitle(String title)
	{
		createTitle();
		titledBorder.setTitle(title);
	}

	public void setITitle(ICSetting iTitle)
	{
		createTitle();
		titledBorder.setI18nTitle(iTitle);
	}

	private void createTitle()
	{
		if (titledBorder == null)
		{
			titledBorder = new RTitledBorder(null, "",
					TitledBorder.DEFAULT_JUSTIFICATION,
					TitledBorder.DEFAULT_POSITION, FontTools.getCustomFont(13),
					Color.CYAN);
			setBorder(titledBorder);
		}
	}
}
